<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8" />
    <title>首页</title>
    <!-- 引入刚刚下载的 ECharts 文件 -->
    <script th:src="@{/echarts/echarts.min.js}"></script>
    <script th:src="@{/echarts/china.js}"></script>
    <script th:src="@{/echarts/jquery-1.11.1.min.js}"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all">
    <script th:src="@{/layui/layui.js}" charset="utf-8"></script>

</head>

<body class="childrenBody">

    <!--layui公共区域-->
    <!--<div th:replace="common :: menu"></div>-->
    <div >
        <!-- 内容主体区域 -->
        <div style="padding: 15px;">
            <!-- 为 ECharts 准备一个定义了宽高的 DOM -->
            <div id="main" style="width: 900px;height:550px;"></div>
        </div>
    </div>
    <script type="text/javascript">
        // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(document.getElementById('main'));
        var dataList = [];

        option = {
            title: {
                text: 'Stacked Line'
            },
            tooltip: {
                trigger: 'axis'
            },
            legend: {
                data: ['确诊人数', '隔离人数', '治愈人数', '死亡人数', '疑似人数']
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            toolbox: {
                feature: {
                    saveAsImage: {}
                }
            },
            xAxis: {
                type: 'category',
                boundaryGap: false,
                data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
            },
            yAxis: {
                type: 'value'
            }
        };

        //发送请求
        $.ajax({
            url: "/queryLine",
            dataType: "json",
            success: function (data) {
                //渲染数据
                myChart.setOption({
                    series: [
                    {
                        name: '确诊人数',
                        type: 'line',
                        stack: 'Total',
                        data: data.confirmList
                    },
                    {
                        name: '隔离人数',
                        type: 'line',
                        stack: 'Total',
                        data: data.isolationList
                    },
                    {
                        name: '治愈人数',
                        type: 'line',
                        stack: 'Total',
                        data: data.cureList
                    },
                    {
                        name: '死亡人数',
                        type: 'line',
                        stack: 'Total',
                        data: data.deadList
                    },
                    {
                        name: '疑似人数',
                        type: 'line',
                        stack: 'Total',
                        data: data.similarList
                    }
                ]
                })
            }
        })

        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    </script>
</body>
</html>